/** @format */

const download = require("download-git-repo");
const myconfig = require("../../config");
const ora = require("ora");

const downFn =  (src, project) => {
  const spinner = ora().start();
  spinner.text = "仓库下载中";
  //   download(`direct:${myconfig.framworkURL[answer.framwork]}`, project, { clone: true }, (err) => console.log(err ? "error" : "success"));
  download(`direct:${myconfig.framworkURL[src]}`, project, { clone: true }, (err) => {
    console.log(err ? "error" : "success");
    if (err) {
      spinner.fail("下载失败！");
    } else {
      spinner.succeed("下载成功！");
    }
  });
};

module.exports = downFn;
